from django.db import models
from django.conf import settings

class Category(models.Model):
    #Category model.
    parent      = models.ForeignKey("self", blank = True, null=True, related_name='children')
    title       = models.CharField(_('title'), max_length=100)
    slug        = models.SlugField(_('slug'), unique=True, editable=False)
    pub_date    = models.DateTimeField(auto_now_add=True)
    status      = models.IntegerField(choices=settings.CONTEST_STATUSES)

    class Meta:
        verbose_name = _('category')
        verbose_name_plural = _('categories')
        ordering = ('title',)

    class Admin:
        pass

    def __unicode__(self):
        return u'%s' % self.title

    def save(self):
        self.slug = slugify(self.title)
        super(Category,self).save()

#    @permalink
#    def get_absolute_url(self):
#        return ('blog_category_detail', None, {'slug': self.slug})
